<?php
require_once substr(dirname(__FILE__),0,-1).'sub/init.php';
if(!in_array('huxuan',$navarr))exit('该功能已关闭');
require_once ZEAI.'sub/conn.php';
require_once ZEAI.'m/div_left_so.php';
$nodatatips = "<div class='nodatatips' style='margin:0 auto'><br><i class='ico'>&#xe608;</i>暂时木有内容</div>";
/***********************主体入口***************************/
$_ZEAI['pagesize']= 5;
$ZEAI_SQL = "a.flag>0 AND a.path_s<>''";
//处理表单
$keyword = trimhtml(dataIO($keyword,'out'));
if (!empty($keyword)){
	if (ifint($keyword)){
		$ZEAI_SQL .= " AND a.id='$keyword' ";
	}else{
		$ZEAI_SQL .= " AND a.title LIKE '%".$keyword."%' ";
	}
}
$jzbmtime=intval($jzbmtime);if(ifint($jzbmtime)){$jzbmtimeF=$jzbmtime*86400;$ZEAI_SQL .= " AND (a.jzbmtime - ".ADDTIME.") < $jzbmtimeF AND a.jzbmtime>".ADDTIME;}
$hxtime=intval($hxtime);if(ifint($hxtime)){$hxtimeF=$hxtime*86400;$ZEAI_SQL .= " AND (a.hxtime - ".ADDTIME.") < $hxtimeF AND a.hxtime>".ADDTIME;}
$flag=trimhtml(dataIO($flag,'out'));if(!empty($flag))$ZEAI_SQL .= doinsql('a.flag',$flag);
//参数
$par = "&sex=".$sex."&jzbmtime=".$jzbmtime."&hxtime=".$hxtime."&flag=".$flag;
$cs  =" keyword=".$keyword.$par;
//主语句
$ZEAI_SELECT = "SELECT id,title,flag,jzbmtime,hxtime,path_s,click FROM ".__TBL_HUXUAN__." a WHERE ".$ZEAI_SQL." ORDER BY a.px DESC,a.id DESC";
//统计
$rtt  = $db->query("SELECT COUNT(*) FROM ".__TBL_HUXUAN__." a WHERE ".$ZEAI_SQL);$roww = $db->fetch_array($rtt);
$ZEAI_total=$roww[0];
$ZEAI_totalP = ceil($ZEAI_total/$_ZEAI['pagesize']);
if ($submitok == 'ajax_list'){
	exit(Zeai_ajax_list_fn($ZEAI_totalP,$p));
}
$kf_tel=dataIO($_ZEAI['kf_tel'],'out');$kf_wxpic=dataIO($_ZEAI['kf_wxpic'],'out'); $kf_mob=dataIO($_ZEAI['kf_mob'],'out');
/*********************** BODY 开始***************************/
$nav = 'index';?>
<!doctype html><html><head><meta charset="utf-8">
<title>线上互选•线下约见 - <?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<meta name="generator" content="Zeai.cn V9" />
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/huxuan.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/zeai_div_area.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php
if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES;?>jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug:false,
		appId: '<?php echo $signPackage["appId"];?>',
		timestamp: <?php echo $signPackage["timestamp"];?>,
		nonceStr: '<?php echo $signPackage["nonceStr"];?>',
		signature: '<?php echo $signPackage["signature"];?>',
		jsApiList: ['hideMenuItems','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo']
	});
	var share_title = '线上互选，线下约见 - <?php echo dataIO($_ZEAI['siteName'],'out'); ?>',
	share_desc  = '全城优质单身男女在线互选，只与你心动的人约见！',
	share_link  = '<?php echo mHref('huxuan'); ?>',
	share_imgUrl= '<?php echo UP.$_ZEAI['logo']; ?>';
	wx.ready(function () {
		wx.onMenuShareAppMessage({title:share_title,desc:share_desc,link:share_link,imgUrl:share_imgUrl});
		wx.onMenuShareTimeline({title:share_title,link:share_link,imgUrl:share_imgUrl});
	});
	</script>
<?php }?>
<style>
.top,.HONG,.party_list a .pic{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
#backtop a,.btmKefuBtn{background-color:#fff;color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.btmKefuBtn i,.btmKefuBtn{color:#333}
/*div_left_so*/
.div_left_so a.ed,
.div_left_so a.ed:after{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so ul.def li.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
.div_left_so .listbox dl dd span.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so_areabox .ul dt.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so_areabox .ul li a.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
.party_list a .djs .timestyle{background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.7)}
/*topnav*/
.topnav1{background-image:url("<?php echo RES;?>m/img/my_bg.png");background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.topnav a.ed:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.topnav1 a.ed:after{background-color:#fff}
</style>
</head><body>
<?php if ($_ZEAI['m_mb']==2){$nav='huxuan';$TRnav_btn = 'hide';require_once ZEAI.'m/top2.php';}else{?>
    <div class="topnav<?php echo ($_ZEAI['m_mb']==1)?' topnav1':'';?>">
        <a class="ed">互选活动</a>
        <?php if($_ZEAI['m_mb']==2){?>
            <font id="huxuan_search"><i class="ico">&#xe68c;</i> 筛选</font></font>
        <?php }else{ ?>
            <a id="huxuan_search"><i class="ico">&#xe68c;</i> 筛选</font></a>
        <?php }?>
    </div>
<?php }?>
<div class="party_list" id="ZEAI_list"><?php if($ZEAI_totalP>0){echo Zeai_ajax_list_fn($ZEAI_totalP,$p);}else{echo $nodatatips;}?></div>
<?php if ($ZEAI_total > $_ZEAI['pagesize']){?>
<script>
var ZEAI_totalP = parseInt(<?php echo $ZEAI_totalP; ?>),p=2;
var scs='<?php echo trimhtml($cs); ?>';
var postjson = {submitok:'ajax_list',ZEAI_totalP:ZEAI_totalP};
if(!zeai.empty(scs))Object.assign(postjson,tojson(scs.split('&')));
zeaiOnscroll_json={url:MHOST+'/huxuan'+zeai.extname,data:postjson};
document.body.onscroll = function(){zeaiOnscroll();};
</script>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<?php }?>
<?php if ($_ZEAI['m_mb']==2){?>
    <a href="javascript:;" id="huxuan_search" class="btmKefuBtn" ><i class="ico">&#xe68c;</i>筛选</a>
<?php }else{ ?>
    <a href="javascript:;" id="btmKefuBtn" class="btmKefuBtn" onClick="ZeaiM.div({obj:btmKefuBox,w:26,h:28});"><i class="ico">&#xe6a6;</i>客服</a>
    <div id="btmKefuBox" class="my-subscribe_box"><img src="<?php echo UP.$kf_wxpic;?>"><h3>长按二维码添加客服微信<br>咨询红娘1对1人工牵线</h3></div>
<?php }?>
<!--div_left_so-->
<div class="div_left_so" id="huxuan_so">
	<form action="<?php echo SELF;?>/m/huxuan.php" class="form_uid" name="www.zeai.cn">
        <input name="keyword" type="text" class="input" id="keyword" maxlength="20" value="<?php echo $keyword;?>" placeholder="按活动ID/名称" autocomplete="off">
        <button type="submit" class="ico">&#xe6c4;</button>
	</form>
    <form action="<?php echo HOST;?>/m/huxuan.php" method="get" name="www.yzlove.com">
    <?php
	div_left_so_out(array('tbody'=>'活动状态','t'=>'flag','tv'=>$flag,'subkind'=>3,'newarr'=>json_decode('[{"i":"1","v":"报名中"},{"i":"2","v":"互选中"},{"i":"3","v":"已结束"}]'),'ulcls'=>' col3'));
	div_left_so_out(array('tbody'=>'报名时间','t'=>'jzbmtime','tv'=>$jzbmtime,'subkind'=>2,'newarr'=>json_decode('[{"i":"3","v":"3天内"},{"i":"7","v":"1周内"},{"i":"30","v":"1月内"}]'),'ulcls'=>' col3'));
	div_left_so_out(array('tbody'=>'互选时间','t'=>'hxtime','tv'=>$hxtime,'subkind'=>2,'newarr'=>json_decode('[{"i":"3","v":"3天内"},{"i":"7","v":"1周内"},{"i":"30","v":"1月内"}]'),'ulcls'=>' col3'));
	?>
    <div class="savebox"><button type="button" class="btn size3 reset" id="div_left_so_resetbtn" onClick="div_left_so_reset('huxuan_so')">重置</button><button type="submit" class="btn size3 zeaibg ico">&#xe6c4; 确定</button></div>
    </form>
</div>
<script>function huxuan_search_btnFn(){ZeaiM.div_left({obj:huxuan_so,w:28});}huxuan_search.onclick=huxuan_search_btnFn;</script>
<!--div_left_so end-->
<?php
if ($ZEAI_total <= $_ZEAI['pagesize']){echo '<div class="blank"></div>';}

if($_ZEAI['m_mb']==2){
	require_once ZEAI.'m/bottom2.php';
}else{
	require_once ZEAI.'m/bottom.php';
}
require_once ZEAI.'m/TRnav.php';
if (is_weixin() && ifint($cook_uid)){wx_endurl('您刚刚浏览的页面【线上互选】',mHref('huxuan'));}
function rows_ulist($rows) {
	global $_ZEAI,$db;
	$fid   = $rows['id'];
	$path_s   = $rows['path_s'];
	$jzbmtime = $rows['jzbmtime'];
	$flag    = $rows['flag'];
	$hxtime  = $rows['hxtime'];
	$title = dataIO($rows['title'],'out');
	$click = $rows['click'];
	$path_b=smb($path_s,'b');
	$path_b_url=UP.$path_b;
	$hot='<i class="ico">&#xe643;</i><font>'.$click.'</font>';
	$echo = '<a href=\''.mHref('huxuan',$fid).'\' clsid="'.$fid.'">';
	$echo .= '<h3>'.$title.'</h3>';
	$echo .= '<div class="pic"><img src="'.$path_b_url.'"></div>';
	$bmnum = $db->COUNT(__TBL_HUXUAN_BMU__,"fid=".$fid);
	$echo .= '<div class="djs">'.party_djs($flag,$jzbmtime).'</div>';
	if($bmnum>0)$echo .= '<dl><dd>'. party_getBmUlist($fid).'<div class="partyflag">'.partyflag($flag).'</div></dd></dl>';//
	//if($flag!=3)$echo .= '<h6><i class="ico">&#xe6c6;</i> <span>互选开始时间：'.YmdHis($hxtime,'YmdHi').'</span></h6>';
	$echo .= '</a>';
	return $echo;
}
function party_getBmUlist($fid) {
	global $db,$_ZEAI,$cook_grade;
	$rt=$db->query("SELECT U.sex,U.photo_s,U.photo_f,U.photo_ifshow,U.flag FROM ".__TBL_HUXUAN_BMU__." a,".__TBL_USER__." U WHERE a.uid=U.id AND U.flag=1 AND a.fid=$fid ORDER BY a.id DESC LIMIT 7");
	$echo = '';
	WHILE ($rows = $db->fetch_array($rt,'num')){
		$sex      = $rows[0];
		$photo_s  = $rows[1];
		$photo_f  = $rows[2];
		$photo_ifshow = $rows[3];
		$uflag    = $rows[4];
		$echo.=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"img"}');
	}
	return $echo;
}
function party_djs($flag,$jzbmtime) {
	$d1  = ADDTIME;
	$d2  = $jzbmtime;
	$totals  = ($d2-$d1);
	$day     = intval( $totals/86400 );
	$hour    = intval(($totals % 86400)/3600);
	$hourmod = ($totals % 86400)/3600 - $hour;
	$minute  = intval($hourmod*60);
	if ($flag >= 2)$totals = -1;
	if (($totals) > 0) {
		$tmp='<span class="jzbmT"><i class="ico">&#xe634;</i> 截止报名还剩</span>';
		if ($day > 0){
			$outtime = $tmp."<span class=timestyle>$day</span>天";
		} else {
			$outtime = $tmp;
		}
		$outtime .= "<span class=timestyle>$hour</span>小时<span class=timestyle>$minute</span>分钟";
	} else {
		$outtime = '　报名已经结束';
	}
	$outtime = '<font>'.$outtime.'</font>';
	return $outtime;
}
function partyflag($flag) {
	switch ($flag){ 
		case 0:$flag_str = "<span class='partyflag0'>未审核</span>";break;
		case 1:$flag_str = "<span class='partyflag1'>报名中</span>";break;
		case 2:$flag_str = "<span class='partyflag2'>互选中</span>";break;
		case 3:$flag_str = "<span class='partyflag3'>已结束</span>";break;
	}
	return $flag_str;
}
?>